import _objectSpread from '@babel/runtime/helpers/esm/objectSpread2';
import React, { Children, cloneElement } from 'react';
import { useFieldContext } from '../../contexts/FieldContext';
import './index.css';
var List = function List(_ref) {
  var value = _ref.value,
    renderItemDetail = _ref.renderItemDetail,
    children = _ref.children;
  var _useFieldContext = useFieldContext(),
    name = _useFieldContext.name;
  return /*#__PURE__*/ React.createElement(
    'div',
    {
      className: 'szzj-form-detail-list',
    },
    (value || []).map(function (item, index) {
      return /*#__PURE__*/ React.createElement(
        'div',
        {
          className: 'szzj-form-detail-item',
          key: index,
        },
        renderItemDetail
          ? renderItemDetail(item, index)
          : /*#__PURE__*/ React.createElement(
              'div',
              {
                className: 'szzj-form-detail-row',
                key: index,
              },
              Children.map(children, function (child) {
                var props = child.props;
                return /*#__PURE__*/ cloneElement(
                  child,
                  _objectSpread(
                    _objectSpread({}, props),
                    {},
                    {
                      name: [name, index, props.name],
                      key: ''.concat(index).concat(props.name),
                    },
                  ),
                );
              }),
            ),
      );
    }),
  );
};
export default List;
